package com.jl.jlapp.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.blankj.utilcode.util.StringUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.jl.jlapp.R;
import com.jl.jlapp.mvp.base.MyApplication;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

public class Tools {
    private static long lastClickTime;
    private static List<Activity> list;

    public static int Dp2Px(Context paramContext, float paramFloat) {
        return (int) (paramFloat * paramContext.getResources().getDisplayMetrics().density + 0.5F);
    }

    public static void addActivity(Activity paramActivity) {
        if (list == null) {
            list = new ArrayList();
        }
        if (list.contains(paramActivity)) {
            return;
        }
        list.add(paramActivity);
    }

    public static boolean checkAliPayInstalled() {
        return new Intent("android.intent.action.VIEW", Uri.parse("alipays://platformapi/startApp")).resolveActivity(MyApplication.getInstance().getPackageManager()) != null;
    }

    public static void finishAll() {
        if (list == null) {
            return;
        }
        if (list.size() != 0) {
            Iterator localIterator = list.iterator();
            while (localIterator.hasNext()) {
                ((Activity) localIterator.next()).finish();
            }
        }
    }

    public static int getVersion() {
        try {
            int i = MyApplication.getInstance().getPackageManager().getPackageInfo(MyApplication.getInstance().getPackageName(), 0).versionCode;
            return i;
        } catch (Exception localException) {
        }
        return -1;
    }

    public static String getVersionName() {
        try {
            String str = MyApplication.getInstance().getPackageManager().getPackageInfo(MyApplication.getInstance().getPackageName(), 0).versionName;
            return str;
        } catch (Exception localException) {
        }
        return "";
    }

    public static String hidePhone(String paramString) {
        String str = paramString;
        if (!StringUtils.isEmpty(paramString)) {
            str = paramString.substring(0, paramString.length() - paramString.substring(3).length()) + "****" + paramString.substring(7);
        }
        return str;
    }

    public static void initRatingBar(RatingBar paramRatingBar, String paramString) {
        if (paramString == null) {
            paramRatingBar.setProgress(paramRatingBar.getMax());
            return;
        }
        if (paramString == "") {
            paramRatingBar.setProgress(paramRatingBar.getMax());
            return;
        }
        paramRatingBar.setProgress((int) (Double.valueOf(paramString).doubleValue() * 20.0D));
    }

    /* Error */
    public static boolean isFastClick(int paramInt) {

        return false;
        // Byte code:
        //   0: ldc 2
        //   2: monitorenter
        //   3: invokestatic 200	java/lang/System:currentTimeMillis	()J
        //   6: lstore_1
        //   7: getstatic 202	com/jl/jlapp/utils/Tools:lastClickTime	J
        //   10: lstore_3
        //   11: lload_1
        //   12: lload_3
        //   13: lsub
        //   14: iload_0
        //   15: i2l
        //   16: lcmp
        //   17: ifge +12 -> 29
        //   20: iconst_1
        //   21: istore 5
        //   23: ldc 2
        //   25: monitorexit
        //   26: iload 5
        //   28: ireturn
        //   29: lload_1
        //   30: putstatic 202	com/jl/jlapp/utils/Tools:lastClickTime	J
        //   33: iconst_0
        //   34: istore 5
        //   36: goto -13 -> 23
        //   39: astore 6
        //   41: ldc 2
        //   43: monitorexit
        //   44: aload 6
        //   46: athrow
        // Local variable table:
        //   start	length	slot	name	signature
        //   0	47	0	paramInt	int
        //   6	24	1	l1	long
        //   10	3	3	l2	long
        //   21	14	5	bool	boolean
        //   39	6	6	localObject	Object
        // Exception table:
        //   from	to	target	type
        //   3	11	39	finally
        //   29	33	39	finally
    }

    public static boolean isNull(String... paramVarArgs) {
        boolean bool2 = false;
        int j = paramVarArgs.length;
        int i = 0;
        for (; ; ) {
            boolean bool1 = bool2;
            if (i < j) {
                if ("".equals(paramVarArgs[i])) {
                    bool1 = true;
                }
            } else {
                return bool1;
            }
            i += 1;
        }
    }

    public static void setCircleIcon(String paramString, ImageView paramImageView) {
        Log.d("useraaaaaaaaaaa", "我执行了设置头像:" + paramString);
        Glide.with(MyApplication.getInstance()).asBitmap().apply(RequestOptions.bitmapTransform(new CircleCrop()).error(R.drawable.icon_user_img).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.icon_user_img)).load(paramString).into(paramImageView).onStart();
    }

    public static void setInputMethod(Activity paramActivity) {
        View localView = paramActivity.getWindow().peekDecorView();
        if (localView != null) {
            ((InputMethodManager) paramActivity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(localView.getWindowToken(), 0);
        }
    }

    public static void setRate(String paramString, TextView paramTextView) {
        String str = MyApplication.getInstance().getString(R.string.text_good_rate, new Object[]{paramString});
        SpannableStringBuilder localSpannableStringBuilder = new SpannableStringBuilder(str);
        localSpannableStringBuilder.setSpan(new ForegroundColorSpan(MyApplication.getInstance().getResources().getColor(R.color.light_blue)), localSpannableStringBuilder.length() - paramString.length(), localSpannableStringBuilder.length(), 17);
        if (!TextUtils.isEmpty(paramString)) {
            paramTextView.setText(localSpannableStringBuilder);
            return;
        }
        paramTextView.setText(str);
    }

    public static String stampToDate(long paramLong) {
        return new SimpleDateFormat("yyyy-MM-dd").format(new Date(paramLong));
    }

    public static void startActivity(Context paramContext, Activity paramActivity) {
        paramContext.startActivity(new Intent(paramContext, paramActivity.getClass()));
    }

    public static void startActivity(Context paramContext, Class paramClass) {
        paramContext.startActivity(new Intent(paramContext, paramClass));
    }

    public static String totalMoney(double paramDouble) {
        paramDouble = new BigDecimal(paramDouble).setScale(2, 4).doubleValue();
        return new DecimalFormat("0.00").format(paramDouble);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/utils/Tools.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */